import { createApp } from 'vue'
import {setupStore} from "./store/index.js";
import website from './config/website.js'
import i18n from './lang/index.js';
// 导入elementui的样式
import 'element-plus/dist/index.css'

import '@smallwei/avue/lib/index.css';
import crudCommon from '/src/mixins/crud.js'
import { getScreen } from './utils/util.js'
import './permission.js';
import basicBlock from './szcomponent/avue/basic-block/main.vue'
import basicContainer from './szcomponent/avue/basic-container/main.vue'
import App from './App.vue'
import {setupRouter} from './router/index.js';
import 'animate.css'
import dayjs from 'dayjs'
import '/src/styles/common.scss';
import {setupGlobDirectives} from "./szdirectives/index.js";
import {setupErrorHandle} from "./logics/error-handle";
/** 常用flex组件 */
import {  Flexbox,  FlexboxItem} from '/src/szcomponent/Flexbox/index.js'
import XrAvatar from '/src/szcomponent/XrAvatar/index.vue'


import FileUpload from '/src/szcomponent/FileUpload/index.js'
import WkFileSelect from '/src/components/NewCom/WkFile/Select/main.js'
import WkPreviewFile from '/src/components/WkPreviewFile/main.js'
import WkImport from '/src/components/WkImport/main.js'
import {setupBus} from "./bus.js";
import {setupAvue} from "./bootstrap/avueBoot.js";
import {setupElementPlus} from "@/bootstrap/elementPlus.js";


window.$crudCommon = crudCommon


async function bootStrap() {
  const app = createApp(App);

  // Configure store
  setupStore(app);


  app.component('basicContainer', basicContainer)
  app.component('basicBlock', basicBlock)

  /** 常用flex组件 以上来自悟空*/
  app.component('flexbox', Flexbox)
  app.component('flexbox-item', FlexboxItem)
  // 下面XrAvater定义了两个，要逐渐取消掉xr-avatar
  app.component('xr-avatar', XrAvatar)
  app.component('XrAvatar', XrAvatar)
  app.use(FileUpload)
  // app.use(WkFileSelect)
  // app.use(WkPreviewFile)
  // app.use(WkImport)
  /** 常用flex组件 以上来自悟空 */

  app.config.globalProperties.$dayjs = dayjs
  app.config.globalProperties.website = website
  app.config.globalProperties.getScreen = getScreen

  setupRouter(app)

  // 注册element组件和图标
  setupElementPlus(app)

  app.use(i18n)

  // 注册avue组件
  setupAvue(app)

  // Register global directive
  setupGlobDirectives(app);

  // Configure global error handling
  setupErrorHandle(app);

  // 注册消息总线
  setupBus(app);
  // https://next.router.vuejs.org/api/#isready
  // await router.isReady();

  app.mount('#app')

}

bootStrap();